<?use pft\Member\MemberAccount;
include 'common/autoload.php';
if(!$_SESSION['memberID']){exit("<script>window.location='dlogin.html'</script>");}
$account=$_REQUEST["account"];
$ps=$_REQUEST["ps"];
$dname=$_REQUEST["dname"];
$mobile=$_REQUEST["mobile"];
$qq=$_REQUEST["qq"];
$address=$_REQUEST["address"];
$m_info=$e_info=array();
$l=strlen($account);
if($l<4 || $l>12){
	echo "<script>alert(\"账号长度应为4~12!\");</script>";
	exit;
}
for($i=0;$i<$l;$i++){
	$t=substr($account,$i,1);
	$v=ord($t);
	if(($v<48||$v>57) && ($v<65||$v>90) && ($v<97||$v>122)){
		echo "<script>alert(\"账号只可由数字与英文构成!\");</script>";
		exit;
	}
}
$m_info['dtype']=6;
$m_info['account']=$account;
$m_info['password']=md5(md5($ps));
$m_info['dname']=$dname;
$m_info['mobile']=$mobile;
$m_info['qq']=$qq;
$m_info['address']=$address;
//var_export($m_info);exit;
$mem = new MemberAccount($GLOBALS['le']);
$res=$mem->register($m_info,$e_info,$_SESSION['sid']);
if($res['status']=="ok"){
	$ins="insert pft_d_operation_rec set fid=".$_SESSION['memberID'].",sid=".$_SESSION['sid'].",daction='创建员工".$account."',rectime=now()";
	$GLOBALS['le']->query($ins);
	echo "<script>alert('添加成功!');</script>";
	exit;
}
else{
	echo "<script>alert(\"".$res['msg']."\")</script>";
}
?>